/**
 * 
 * 
 */
var randomUtils = {
	Int: function(min, max) {
		if(max == undefined) {
			var max = min;
			var min = 0;
		}
		return Math.round(Math.random() * (max - min)) + min;
	}
}
var eventUtils = {
	addEvent: function(ele, eventName, callback, isCapure) {
		if(ele.addEventListener) {
			ele.addEventListener(eventName, callback, !!isCapure);
			eventUtils.addEvent = function(ele, eventName, callback, isCapure) {
				ele.addEventListener(eventName, callback, !!isCapure);

			}
		} else {
			ele.attachEvent('on' + eventName, callback);
			eventUtils.addEvent = function(ele, eventName, callback) {
				ele.attachEvent('on' + eventName, callback);
			}
		}
	},
	removeEvent: function(ele, eventName, callback) {
		if(ele.removeEventListener) {
			ele.removeEventListener(eventName, callback);
			eventUtils.removeEvent = function(ele, eventName, callback) {
				ele.removeEventListener(eventName, callback);
			}
		} else {
			ele.detachEvent('on' + eventName, callback);
			eventUtils.removeEvent = function(ele, eventName, callback) {
				ele.detachEvent('on' + eventName, callback);
			}
		}
	}

}

function $(target) {
	var match = null;
	// #id
	if(match = target.match(/^#(.+)/)) {
		return document.getElementById(match[1]);
	}
	// .class
	if(match = target.match(/^\.(.+)/)) {
		return document.getElementsByClassName(match[1])[0];
	}
	// div
	if(match = target.match(/^[^#\.][a-zA-Z]+[0-9]?$/)) {
		return document.getElementsByTagName(match[1])[0];
	}
}

function $$(target) {
	var match = null;
	// .class
	if(match = target.match(/^\.(.+)/)) {
		return document.getElementsByClassName(match);
	}
	// div
	if(match = target.match(/^[^#\.][a-zA-Z]+[0-9]?$/)) {
		return document.getElementsByTagName(match);
	}
}

function getStyle(ele, attr, isUnit) {
	if(getComputedStyle) {
		return !!isUnit ? getComputedStyle(ele)[attr] : parseInt(getComputedStyle(ele)[attr]);

		}
		return !!isUnit ? ele.currentStyle[attr] : parseInt(ele.currentStyle[attr]);
	}